import { BaseWindow } from "../../../component/window/BaseWindow";
import { ParamsConst } from "../../../common/global/ParamsConst";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { BrowerManager } from "../../../../com/gengine/manager/BrowerManager";
import { GButton } from "../../../../com/mui/controls/GButton";
//class FavoriteWindow
    
    export  class FavoriteWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this._gameName = ParamsConst.instance.gameName;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            this.setSize(330, 215);
            this.titleHeight = 28;
            this.title = Language.getString(51001) + this._gameName;
            ObjCreate.createBg(17, 39, 295, 163, this);
            loc1 = ObjCreate.createGLoadedButton(ResFileConst.Favorite, 130, 60, 60, 60, this);
            loc1.mouseEnabled = false;
            loc1.mouseChildren = false;
            this._tipTxt = ObjCreate.createTextField("", 25, 135, 250, 50, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.htmlText = Language.getStringByParam(51002, this._gameName);
            this._okBtn = ObjCreate.createGButton(Language.getString(51003), 130, 160, 70, 24, this);
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.AddFavorite));
            BrowerManager.instance.addFavorite(ParamsConst.instance.title, ParamsConst.instance.favoritesUrl);
            this.hide();
            return;
        }

        public static get instance(): FavoriteWindow
        {
            if (!FavoriteWindow._instance) 
            {
                FavoriteWindow._instance = new FavoriteWindow();
            }
            return FavoriteWindow._instance;
        }

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tip: string="";

        /* internal */ /* var */_gameName: string;

        /* internal */ static /* var */_instance: FavoriteWindow;
    }
